<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>预编译</title>
</head>
<body>
    <script>
        //全局预编译
        console.log(a)
        var a = 100;
        function a(){}
        console.log(a)
        /* 代码执行前进行预编并生成变量对象VO，会先将var定义的a作为属性名，值为undefined
            并继续寻找函数声明，如果重复会将函数覆盖变量声明
        */


        //函数预编译
        function fn (a, c) {
            console.log(a)
            var a = 123
            console.log(a)
            console.log(c)
            function a () {}
                if (false) {
                    var d = 678
                }
            console.log(d)
            console.log(b)
            var b = function () {}
            console.log(b)
            function c () {}
            console.log(c)
        }
        fn(1, 2)
            
      
    
    </script>
</body>
</html>